home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / xmsbcp11.zip / PASCAL / TEST.PAS next >
Pascal/Delphi Source File  |  1997-04-13  |  2KB  |  70 lines

  1.  
  2. {-----------------------------------------------------------------------}
  3. {                                    }
  4. {    XMS Interface Unit for Borland Pascal 7.0, Version 1.1        }
  5. {    Developed by Tanescu A. Horatiu                    }
  6. {    April 1997                            }
  7. {                                    }
  8. {-----------------------------------------------------------------------}
  9. {    Test program                            }
  10. {-----------------------------------------------------------------------}
  11.  
  12. program XMSDemo;
  13.  
  14. uses XMS;
  15.  
  16. var
  17.   Handle : Word;  { handle to the eXtended memory block to be allocated    }
  18.   Size   : Word;  { size of the block to allocate            }
  19.   S      : string;{ what to write in eXtended memory            }
  20.   SLen   : Byte;  { length of S                        }
  21.  
  22. begin
  23.  
  24.   if (XMSInstalled = False) then    { XMS initialization error    }
  25.   begin
  26.     WriteLn('Can''t use XMS: No XMS Driver Installed!');
  27.     Halt(1)
  28.   end;
  29.  
  30.   { print some statistics                        }
  31.   WriteLn;
  32.   WriteLn('Free extended memory:               ', XMFreeSpace : 5, 'K');
  33.   WriteLn('Largest free extended memory block: ', XMContig    : 5, 'K');
  34.   WriteLn;
  35.  
  36.   Size   := 1;            { we will allocate 1 K-byte        }
  37.   Str(Size, S);
  38.  
  39.   Handle := XMAlloc(Size);    { allocate an eXtended memory block    }
  40.   if Handle = 0 then        { allocation error            }
  41.   begin
  42.     { write an error message and exit                    }
  43.     PrintXMSError('Can''t allocate ' + S + 'K');
  44.     Halt(1)
  45.   end
  46.   else WriteLn('Allocated ' + S + 'K');
  47.  
  48.   WriteLn;
  49.   WriteLn('The following text is about to be written in eXtended memory:');
  50.   S := 'Hello, world'; SLen := Length(S);
  51.   WriteLn(S);
  52.  
  53.   { copy string into extended memory block                }
  54.   CopyCMemToXMem(Handle, 0, Addr(S), SLen);
  55.  
  56.   S := '';
  57.  
  58.   { retreive string from extended memory block                }
  59.   CopyXMemToCMem(Addr(S), Handle, 0, SLen);
  60.  
  61.   WriteLn('The following text was read back from eXtended memory:');
  62.   WriteLn(S);
  63.  
  64.   XMFree(Handle);        { free block                }
  65.  
  66.   { print some statistics                        }
  67.   WriteLn;
  68.   WriteLn('Free extended memory:               ', XMFreeSpace : 5, 'K');
  69.   WriteLn('Largest free extended memory block: ', XMContig    : 5, 'K')
  70. end.